﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.facebook.utils {
    import flash.events.*;
    import flash.utils.*;

    public class FacebookArrayCollection extends EventDispatcher {

        protected var _source:Array;
        protected var hash:Dictionary;
        protected var _type:Class;

        public function FacebookArrayCollection(_arg1:Array=null, _arg2:Class=null){
            this.reset();
            this._type = _arg2;
            this.initilizeSource(_arg1);
        }
        protected function verifyIndex(_arg1:uint):void{
            if (this._source.length < _arg1){
                throw (new RangeError((("Index: " + _arg1) + ", is out of range.")));
            };
        }
        public function addItem(_arg1:Object):void{
            this.addItemAt(_arg1, this.length);
        }
        public function get length():int{
            return (this._source.length);
        }
        public function addItemAt(_arg1:Object, _arg2:uint):void{
            if (this.hash[_arg1] != null){
                throw (new Error("Item already exists."));
            };
            if (((!((this._type === null))) && (!((_arg1 is this._type))))){
                throw (new TypeError((("This collection requires " + this._type) + " as the type.")));
            };
            this.hash[_arg1] = true;
            this._source.splice(_arg2, 0, _arg1);
        }
        public function indexOf(_arg1:Object):int{
            return (this._source.indexOf(_arg1));
        }
        public function removeItemAt(_arg1:uint):void{
            this.verifyIndex(_arg1);
            var _local2:Object = this._source[_arg1];
            delete this.hash[_local2];
            this._source.splice(_arg1, 1);
        }
        public function getItemAt(_arg1:uint):Object{
            this.verifyIndex(_arg1);
            return (this._source[_arg1]);
        }
        override public function toString():String{
            return (this._source.join(", "));
        }
        public function reset():void{
            this.hash = new Dictionary(true);
            this._source = [];
        }
        protected function initilizeSource(_arg1:Array):void{
            this._source = [];
            if (_arg1 == null){
                return;
            };
            var _local2:uint = _arg1.length;
            var _local3:uint;
            while (_local3 < _local2) {
                this.addItem(_arg1[_local3]);
                _local3++;
            };
        }
        public function findItemByProperty(_arg1:String, _arg2:Object, _arg3:Boolean=false):Object{
            var _local4:Object;
            for (_local4 in this.hash) {
                if (((((_arg3) && ((_arg1 in _local4)))) && ((_local4[_arg1] === _arg2)))){
                    return (_local4);
                };
                if (((((!(_arg3)) && ((_arg1 in _local4)))) && ((_local4[_arg1] == _arg2)))){
                    return (_local4);
                };
            };
            return (null);
        }
        public function get type():Class{
            return (this._type);
        }
        public function get source():Array{
            return (this._source);
        }
        public function toArray():Array{
            var _local1:Array = [];
            var _local2:uint = this.length;
            var _local3:uint;
            while (_local3 < _local2) {
                _local1.push(this.getItemAt(_local3));
                _local3++;
            };
            return (_local1);
        }
        public function contains(_arg1:Object):Boolean{
            return ((this.hash[_arg1] === true));
        }

    }
}//package com.facebook.utils 
